<?php

class FormComboBox extends FormControl {
	
	
	public static $property = array(
		'wbtype',
		'name',
		'caption',
		'x',
		'y',
		'width',
		'height',
		'disabled',
		'sort',
		'readOnly',
		'visible'
	);	
	
	public function __construct() { 
		parent::__construct(array(
			'wbtype' => 'ComboBox',
			'caption' => 'a,b,c',
			'x' => 0,
			'y' => 0,
			'width' => 100,
			'height' => 20
		));
	}
	
	/**
	 * 컨트롤 그리기 
	 * 
	 * @param WBGraphics $graphics
	 */
	public function displayControl(WBGraphics $g) {
		
		$xstart = $this->getOption('x');
		$ystart = $this->getOption('y');
		$width = $this->getOption('width');
		$height = $this->getOption('height');		
		$xcenter = $xstart + $width / 2;
		$xend = $xstart + $width;
		$ymiddle = $ystart + $height / 2;
		$yend = $ystart + $height;	
		
		if ($this['line']) { 
			$g->rect($xstart, $ystart, $width, $height, FormControl::OUTLINE, false, 0, 3);
		}
		
		$title = explode(",", $this['caption']);
		
		$color = NOCOLOR;
		
		if ($this['disabled'] && $this['readonly']) { 
			$color = FormControl::DISABLED;
		} else { 
			$color = FormControl::EDIT;
		}
		
		// draw editbox 
		if(ProjectManager::$checkWireFrame->isChecked()) {
			$g->rect($xstart, $ystart, $width, $height, FormControl::SHADE, false, 1, WBGraphics::LINE_DOTTED);
		} else {
			$g->rect($xstart, $ystart, $width, 18, $color, true);
			$g->line($xend - 2, $ystart, $xend - 2, $yend - 2, FormControl::EDITSHADE);
			$g->line($xstart, $yend - 2, $xend - 2, $yend - 2, FormControl::EDITSHADE);
			$g->line($xstart, $ystart, $xend - 2, $ystart, FormControl::SHADOW);
			$g->line($xstart, $ystart, $xstart, $yend - 2, FormControl::SHADOW);
		}	
		
	
		$style = WBC_LEFT | WBC_TOP;
		$font = ($this['disabled']) ? self::$disabledFont : self::$realFont ;
		$g->text($title[0], $xstart + 4, $ystart + 2, $width - 4, $height - 2, $font, $style);
			  
		$this->displayButton($g, $titles[0], $xstart + $width - 19, $ystart + 1, 18, 18);
		
		if ($width > 7 && $height > 11) { 
			$g->image(self::$dnarrow, $xstart + $width - 19 + 6, $ystart + 8, 7, 4, BLACK);			
		}		

	}

	
	public function getProperty() { 
		return self::$property;
	}	
	
}


?>